package com.bjpowernode.crm.web.interceptor;

import com.bjpowernode.crm.pojo.User;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class MyInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //获取存在session在的登录账号，如果没有获取，就说明登录证明已过期，要求重新登录，安全因素
        User loginUser =(User) request.getSession().getAttribute("loginUser");
            if(loginUser !=null){
                return true;
            }else {
                response.sendRedirect("WEB-INF/jsp/index.html");
                return false;
            }
    }
}
